package com.example.speeddating.service.impl;

import com.example.speeddating.entity.Photo;
import com.example.speeddating.mapper.PhotoMapper;
import com.example.speeddating.service.PhotoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author tina
 * @since 2023-07-12 02:40:06
 */
@Service
public class PhotoServiceImpl extends ServiceImpl<PhotoMapper, Photo> implements PhotoService {

    @Autowired
    private PhotoMapper photoMapper;


    @Transactional(rollbackFor = Exception.class)
    @Override
    public int insertPhoto(Photo photo) {
        return photoMapper.insert(photo);
    }


    @Transactional(rollbackFor = Exception.class)
    @Override
    public int deletePhoto(Long id) {
        return photoMapper.deleteById(id);
    }

    @Override
    public Photo getFirstPhotoByUserId(Long userId) {
        return photoMapper.getFirstPhotoByUserId(userId);
    }
}
